package com.harlan.viewbindingstudy.mvp;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.viewbinding.ViewBinding;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;

import com.harlan.viewbindingstudy.BlankFragment;
import com.harlan.viewbindingstudy.BlankFragment2;
import com.harlan.viewbindingstudy.BlankFragment3;

import com.harlan.viewbindingstudy.BlankFragment4;
import com.harlan.viewbindingstudy.FragmentAdpter;
import com.harlan.viewbindingstudy.R;
import com.harlan.viewbindingstudy.base.mvp.XActivity;
import com.harlan.viewbindingstudy.databinding.ActivityMvpactivityBinding;
import com.harlan.viewbindingstudy.mvp.present.MvpPresent;

import java.util.ArrayList;
import java.util.List;

public class MVPActivity extends XActivity<MvpPresent> {

    ActivityMvpactivityBinding binding;
    List<Fragment> fragments = new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        FragmentManager manager = getSupportFragmentManager();
        fragments.add(new BlankFragment4());
        fragments.add(new BlankFragment2());
        fragments.add(new BlankFragment3());
        FragmentAdpter adpter = new FragmentAdpter(manager, fragments);
        binding.mvpViewBing.setAdapter(adpter);
    }

    @Override
    protected View getViewBinding() {
        binding = ActivityMvpactivityBinding.inflate(getLayoutInflater());
        return binding.getRoot();
    }




    public void ShowMVP(String s) {
        binding.viewbingMvp.setText(s);
    }


    @Override
    public void initData(Bundle savedInstanceState) {
        getP().netWorrk();
        // binding.viewbingMvp.setText("我是封装基类使用的viewbing");
    }

    @Override
    public int getLayoutId() {
        return 0;
    }


    @Override
    public MvpPresent newP() {
        return new MvpPresent();
    }
}